﻿using System;
using System.Collections.Generic;
using System.Data;
using System.Linq;
using System.Text;
using WmsApp.WmsService;

namespace WmsApp.Service
{
    public class CustomerService :IEntityService<Customer,CustomerService>
    {

        #region IEntityService<Customer> Members

        public List<Customer> GetEntityList()
        {
            var sc = Factory.WmsServiceFactory.GetServiceClient();
            List<Customer> list = sc.GetCustomers();
            foreach (var customer in list)
            {
                customer.BindPropertyChanged();
            }
            return list;
        }

        public List<Customer> GetEntityList(string condition)
        {
            var list = Factory.WmsServiceFactory.GetServiceClient().GetCustomersByCondition(condition);
            foreach (var customer in list)
            {
                customer.BindPropertyChanged();
            }
            return list;
        }

        public void SaveEntityList(List<Customer> list)
        {
            var sc = Factory.WmsServiceFactory.GetServiceClient();
            sc.SaveCustomers(list);
            foreach (var c in list)
            {
                c.WcfEntityState = EntityState.Unchanged;
            }
        }

        public Customer GetEntity(string key)
        {
            throw new NotImplementedException();
        }

        #endregion

    }
}
